using System;
using System.Diagnostics;
using System.Linq;
using Divan;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SurveySharp.Model;

namespace SurveySharp
{
	class MainClass
	{
		public static void Main (string[] args)
		{
            string host = "localhost";
            int port = 5984;
			var server = new CouchServer(host, port);
			var db = server.GetDatabase("trivial");
			/*
			var def = new SurveyDefinition()
			{
				CreationDate = DateTime.Now,
				Name = "Encuesta de prueba2",
				Id = "A8"
				//Version = 1,
				//_id = "A1"
			};
			
			//var doc = new CouchDocumentWrapper<SurveyDefinition>(def);
			db.SaveArbitraryDocument(def);
			*/
			var defObtenida = db.GetArbitraryDocument<SurveyDefinition>("A8", () => new SurveyDefinition());
			Console.WriteLine(defObtenida.Name);
			Console.WriteLine("Una tecla para continuar...");
			Console.ReadLine();
		}
	}
}
